<?php	
	require_once('../../lib/'.'BaseDir.inc.htm');
	require_once (EIU_LIB.'View.class.htm');
	require_once(EIU_LIB.'DBCommon.class.htm');
	require_once (EIU_CLASS.'AssetClass.htm');	
	
	$assetObj = new asset_class();
	//san pham khong BarCode
	$assName = $_POST['assName'];
	$catCode=$_POST["catCode"];
	$localID = 0;// mặc định phong giao thiet bi
	
	//Tong so luong thiet bi nhap vao bang Asset ban dau
	$sumQualityImportInAsset = $assetObj->getSumQuantityOfAsset($assName,$localID,$catCode);
	
	$data["dataSearch"]["quantityIn"] = $sumQualityImportInAsset[0]->Total;
	$data['dataSearch']['unit'] = $sumQualityImportInAsset[0]->Unit;
			
	//Tong so luong thiet bi xuat cho cac phong ban
	$sumQualityExportOutDetailIO = $assetObj->getSumQuantityOfDetailIO($assName, $localID, $catCode, 'X');
	$data["dataSearch"]["quantityOutDepartment"] = $sumQualityExportOutDetailIO;	
	
	//Tong so luong thiet bi nhap tu cac phong ban khac
	//$sumQualityExportInDetailIO = $assetObj->getSumQuantityOfDetailIO($assName, $localID, $catCode, 'N');
	//$data["dataSearch"]["quantityInDepartment"] = $sumQualityExportInDetailIO;
	$data["dataSearch"]["quantityInDepartment"] = 0;
	
	
	//Tong so luong thiet bi ton kho cua phong giao thiet bi
	$data["dataSearch"]["quantityInStock"] = $data["dataSearch"]["quantityIn"] + $data["dataSearch"]["quantityInDepartment"] - $data["dataSearch"]["quantityOutDepartment"];
	
	//Giá sản phẩm dựa trên Item
	$assetPriceInfo = $assetObj->getAssetNoBarcodePrice($catCode,$assName);
	$data["dataSearch"]["price"] = $assetPriceInfo[0]->{"Price"};
	//$data["dataSearch"]["unit"] = $assetPriceInfo[0]->{"Unit"};
	
	$json = json_encode($data["dataSearch"]);	
	echo $json;	
?>